package com.tender.controller;

import com.tender.SysMsgInfoBizService;
import com.tender.page.PageDTO;
import com.tender.dto.SysMsgInfoDTO;
import com.tender.common.Result;
import com.tender.condition.SysMsgInfoCondition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 这部分放到运营平台
 */
@RestController
@RequestMapping("/api/ws/op/sysMsg")
public class SystemMsgInfoController {

    @Autowired
    private SysMsgInfoBizService sysMsgInfoBizService;

    @GetMapping("/detail/{id}")
    public Result<SysMsgInfoDTO> detail(@PathVariable("id") Long id) {
        return Result.success(sysMsgInfoBizService.detail(id));
    }

    /**
     * 面向【管理后台】的分页查询
     */
    @PostMapping("/page/list/manage")
    public Result<PageDTO<SysMsgInfoDTO>> pageListManage(@RequestBody SysMsgInfoCondition condition) {
        return Result.success(sysMsgInfoBizService.pageListManage(condition));
    }

    /**
     * 面向【用户消息】的分页查询
     */
    @PostMapping("/page/list/user")
    public Result<PageDTO<SysMsgInfoDTO>> pageListUser(@RequestBody SysMsgInfoCondition condition) {
        return Result.success(sysMsgInfoBizService.pageListUser(condition));
    }

    @GetMapping("/online/{id}")
    public Result<Boolean> online(@PathVariable("id") Long id) {
        return Result.success(sysMsgInfoBizService.online(id));
    }

    @GetMapping("/offline/{id}")
    public Result<Boolean> offline(@PathVariable("id") Long id) {
        return Result.success(sysMsgInfoBizService.offline(id));
    }

    @PostMapping("/modify")
    public Result<Boolean> modify(@RequestBody SysMsgInfoDTO param) {
        return Result.success(sysMsgInfoBizService.modify(param));
    }

    @GetMapping("/remove/{id}")
    public Result<Boolean> remove(@PathVariable("id") Long id) {
        return Result.success(sysMsgInfoBizService.remove(id));
    }

}
